﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;

public partial class guanli : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            tt();
        }
    }
    public void tt()
    {
        Class1 cc = new Class1();
        //string str = "select * from Message";
        DataSet ds = cc.GetMessages();
        GridView1.DataSource = ds;
        GridView1.DataBind();
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        tt();
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        
    }

    protected void GridView2_RowDeleted(object sender, GridViewDeletedEventArgs e)
    {

    }
    protected void GridView1_RowDeleting1(object sender, GridViewDeleteEventArgs e)
    {
        Class1 cc = new Class1();
        int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
        string sql = "Delete from Message where ID=" + id;
        int i = cc.ExecSql(sql);
        if (i > 0)
        {
            Response.Write("<script>alert('确认删除？')</script>");

        }
        else
        {
            Response.Write("<script>alert('删除失败')</script>");
        }
    }
}


